﻿SSVC.Utils.Page.IncludeFile("../styles/ReplyToolbar.css", "css");

SSVC.Wrap.Dojo.Require([
    "dojo/_base/fx",
    "dojo/_base/lang",
    "dojo/dom-style",
    "dojo/mouse",
    "dojo/on",
    "dijit/_WidgetBase",
    "dijit/_TemplatedMixin",
    "dojo/text!../scripts/ReplyToolbar.html"],

	function(baseFx, lang, domStyle, mouse, on, _WidgetBase, _TemplatedMixin, template)
	{
		return SSVC.Wrap.Dojo.SetObject("SSVC.UI.ReplyToolbar", SSVC.Wrap.Dojo.Declare([_WidgetBase, _TemplatedMixin, SSVC.UI.TemplateControl],
			{
				templateString: template,

				ReplyToolbarText: SSVC.Utils.GetResource("feed_tb_def_comment"),

				constructor: function()
				{
					this.id = "ReplyToolbar";
				},

				postCreate: function()
				{
					this.own(
						on(this.taReplyTextNode, "click", lang.hitch(this, "ElementOnFocus", this.taReplyTextNode, "Enter a comment...")),
						on(this.taReplyTextNode, "blur", lang.hitch(this, "ElementOnBlur", this.taReplyTextNode, "Enter a comment...")),
						on(this.taReplyTextNode, "keyup", lang.hitch(this, "taReplyText_OnKeyUp")),
						on(this.btReplyNode, "click", lang.hitch(this, "btReply_OnClick")));
				},

				GetMessageText: function()
				{
					return SSVC.Utils.Page.EncodeHTML(this.taReplyTextNode.value);
				},

				SetVisibility: function(newVisibility)
				{
					this.domNode.style.display = newVisibility;
				},

				GetVisibility: function()
				{
					return this.domNode.style.display;
				},

				SetIndent: function(newIndent)
				{
					this.domNode.style.marginLeft = newIndent + "px";
				},

				OnReplyTextKeyUp: function() { },
				OnReplyButtonClick: function() { },

				//events								
				taReplyText_OnKeyUp: function()
				{
					this.OnReplyTextKeyUp(arguments[0]);
				},
				btReply_OnClick: function()
				{
					this.OnReplyButtonClick(arguments, this);
				}
			}));
	});